﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Tool.hbm2ddl;

namespace PhotoBook.Repositorio
{
    public class NHConfig
    {
        private static ISessionFactory _Session; 

        static NHConfig()
        {
            var config = new NHibernate.Cfg.Configuration();
            config.Configure(typeof(PhotoBook.Model.Entities.Album).Assembly, "PhotoBook.Model.Hibernate.cfg.xml");
            config.AddAssembly(typeof(PhotoBook.Model.Entities.Album).Assembly);
            new SchemaExport(config).Execute(false, true, false);
            _Session = config.BuildSessionFactory();
        }

        public static ISessionFactory GetSession()
        {
            return _Session;
        }
    }
}
